from django import forms
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, UsernameField
from captcha.fields import CaptchaField
from .models import User


class RegisterForm(UserCreationForm):
    captcha = CaptchaField(label='验证码', error_messages={
        'invalid': '验证码错误！'
    })

    class Meta(UserCreationForm.Meta):
        model = User
        fields = ("username", "email", "gender", "date_born", "occupation")
        labels = {
            'gender': '性别',
            'date_born': '出生日期',
            'occupation': '行业',
        }
